﻿using Cofe.Core;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Cofe.Core.Validater
{
    public class StreamActionAttribute : ActionAttribute
    {


        private static Type getOutputType(FileAccess accessMode)
        {
#if NETFX_CORE
            switch (accessMode)
            {
                case FileAccess.Read:
                    return typeof(Windows.Storage.Streams.IInputStream);
                case FileAccess.Write:
                    return typeof(Windows.Storage.Streams.IOutputStream);
                default:
                    throw new NotSupportedException();
            }
#else
            return typeof(System.IO.Stream);
#endif
        }

        public StreamActionAttribute(ActionType actionType, FileAccess accessMode, params string[] parameters)
            : base(actionType, typeof(StreamContainer), parameters)
        {
            _accessMode = accessMode;
        }

        private FileAccess _accessMode;

        public override ValidationResult GetValidationResult(object value)
        {
            ValidationResult retVal = base.GetValidationResult(value);

            if (retVal == ValidationResult.Success)
            {
#if NETFX_CORE
                //TO-DO: Check Stream 
                return ValidationResult.Success;
#else
                return ValidationResult.Success;
#endif
            }

            else return retVal;
        }


    }
}
